package top.likeqc.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.likeqc.common.lang.Result;
import top.likeqc.dto.PaperAnswerDTO;
import top.likeqc.dto.PaperAnswerDTO2;
import top.likeqc.entity.Answer;
import top.likeqc.service.IAnswerService;

import java.util.List;

/**
 * <p>
 * 答案 前端控制器
 * </p>
 *
 * @author likeqc
 * @since 2022-04-16
 */
@RestController
@RequestMapping("/answer")
public class AnswerController extends BaseController {
    @Autowired
    IAnswerService answerService;

    @GetMapping("/{paperId}")
    public Result getPaperAnswerByPaperId(@PathVariable Long paperId) {
        PaperAnswerDTO data = answerService.getPaperAnswerByPaperId(paperId);
        return Result.success(data);
    }

    @GetMapping("/analysis/{paperId}")
    public Result getAnalysisByPaperId(@PathVariable Long paperId) {
        List<PaperAnswerDTO2> data = answerService.getPaperAnswerByPaperId2(paperId);
        return Result.success(data);
    }


    @PostMapping()
    public Result edit(@RequestBody List<Answer> answerList) {

        answerService.edit(answerList);
        return Result.success("提交成功");
    }
}
